import { userInfoResult, userLoginForm, userLoginResult } from '@/types/user'
import { httpRequest } from '@/http/request'
/**用户登录接口 */
export function loginService(data: userLoginForm) {
  return httpRequest<userLoginResult>({
    url: '/sys/login',
    method: 'post',
    data,
  })
}
/**获取用户个人信息 */
export const getUserInfoService = () => {
  return httpRequest<userInfoResult>({
    url: '/sys/getUserInfo',
    method: 'get',
  })
}
/**用户登出接口 */
export const logoutService = (userId: string) => {
  return httpRequest({
    url: '/sys/logout',
    method: 'post',
    data: { userId },
  })
}
/** 教师姓名模糊搜索 */
export const getInstructorListService = (name: string) => {
  return httpRequest({
    url: '/sys/getUserName',
    method: 'get',
    params: { name },
  })
}
/**判断用户信息是否完善 */
export const checkUserInfoService = () => {
  return httpRequest<boolean>({
    url: '/sys/isUserInfoComplete',
    method: 'get',
  })
}
/**获取手机验证码功能 */
export const getPhoneCodeService = (data) => {
  return httpRequest({
    url: '/sys/getPhoneCode',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json',
    },
  })
}
/**修改用户信息 */
export const updateUserInfoService = (data: userInfoResult) => {
  return httpRequest({
    url: '/instructor/editInstructor',
    method: 'post',
    data,
  })
}
/**增加用户 */
export const addUserService = (data: userInfoResult) => {
  return httpRequest({
    url: '/instructor/addInstructor',
    method: 'post',
    data,
  })
}
/**删除用户 */
export const deleteUserService = (ids: string[]) => {
  return httpRequest({
    url: '/instructor/deleteInstructor',
    method: 'post',
    data: { ids },
  })
}
/**获取部门负责人的信息 ids部门id */
export const getFirstDeptInstructorsService = (ids: string[], type: string = 'school') => {
  return httpRequest<userInfoResult[]>({
    url: '/instructor/getOnePeople',
    method: 'post',
    data: { ids },
    params: { type },
  })
}
